package cn.com.klun.util;

import java.util.ResourceBundle;

/**
 * TODO 了解这个类的作用 项目的基本配置信息
 */
public class BasisConstants {

	/**子任务生成组*/
	public static final String CHILD_TASK_CREATE = "CHILD_TASK_CREATE";

	/**子任务执行组*/
	public static final String CHILD_TASK_RUN = "CHILD_TASK_RUN";
	
	/**系统保障任务组*/
	public static final String SYSTEM_TASK_GROUP = "SYSTEM_TASK_GROUP";
	
	/**数据库driverClassName*/
	public static String driverClassName = "";
	
	/**数据库driverUrl*/
	public static String driverUrl = "";
	
	/**数据库账号*/
	public static String account = "";
	
	/**数据库密码*/
	public static String password = "";
	
	/**任务参数变更监听器执行规则*/
	public static String taskConfigRule = "";
	
	/**任务死锁监听器执行规则 */
	public static String TaskDeadlockRule = "";
	
	/**任务死锁监听器执行规则 */
	public static String Redis_Basic_key = "";
	
	public static int threadCount = 0;
	
	static{
		ResourceBundle rb = ResourceBundle.getBundle("props/tjy-task");
		driverClassName = rb.getString("driverClassName");
		driverUrl = rb.getString("driverUrl");
		account = rb.getString("account");
		password = rb.getString("password");
		//加密 给password
		if (isEncryptProp(password)) {
			String decryptValue = getAesDeCode(password.replace("{AES}", ""));
			password = decryptValue;
		}
		taskConfigRule = rb.getString("taskConfigRule");
		TaskDeadlockRule = rb.getString("TaskDeadlockRule");
		Redis_Basic_key = rb.getString("Redis_Basic_key");
		threadCount = Integer.valueOf(rb.getString("threadCount").trim());
	}
	
	
	/**
	 * 判断是否是加密的属性
	 * 
	 * @param propertyValue
	 * @return
	 */
	private static boolean isEncryptProp(String propertyValue) {
		if (propertyValue.startsWith("{AES}")) {
			return true;
		}
		return false;
	}
	private static String getAesDeCode(String value) {
		return MainSecurity.decode(value);
	}
	/**资产包的状态：出售中，030*/
	public static String PACKAGE_STAT_CSZ = "030";
	
	/**资产包的状态：售尽，060*/
	public static String PACKAGE_STAT_SJ = "060";
	
	/**锁定位：初始化，01*/
	public static String LOCK_FLG_INIT = "01";
	
	/**锁定位：锁定，02*/
	public static String LOCK_FLG_LOCK = "02";
}
